package com.ruoyi.aftserv.controller;

import java.util.List;

import com.ruoyi.aftserv.domain.AfterServiceApplyInfoQuery;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.aftserv.domain.AfterServiceApplyInfo;
import com.ruoyi.aftserv.service.IAfterServiceApplyInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生报名管理Controller
 * 
 * @author 张艳羽
 * @date 2024-08-22
 */
@Controller
@RequestMapping("/aftserv/applyInfo")
public class AfterServiceApplyInfoController extends BaseController
{
    private String prefix = "aftserv/applyInfo";

    @Autowired
    private IAfterServiceApplyInfoService afterServiceApplyInfoService;

    @RequiresPermissions("aftserv:applyInfo:view")
    @GetMapping()
    public String applyInfo()
    {
        return prefix + "/applyInfo";
    }

    /**
     * 查询学生报名管理列表
     */
    @RequiresPermissions("aftserv:applyInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AfterServiceApplyInfoQuery query)
    {
        startPage();
        List<AfterServiceApplyInfoQuery> list = afterServiceApplyInfoService
                .selectAfterServiceApplyInfoQueryList(query);
        return getDataTable(list);
    }

    /**
     * 导出学生报名管理列表
     */
    @RequiresPermissions("aftserv:applyInfo:export")
    @Log(title = "学生报名管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AfterServiceApplyInfo afterServiceApplyInfo)
    {
        List<AfterServiceApplyInfo> list = afterServiceApplyInfoService.selectAfterServiceApplyInfoList(afterServiceApplyInfo);
        ExcelUtil<AfterServiceApplyInfo> util = new ExcelUtil<AfterServiceApplyInfo>(AfterServiceApplyInfo.class);
        return util.exportExcel(list, "学生报名管理数据");
    }

    /**
     * 新增学生报名管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存学生报名管理
     */
    @RequiresPermissions("aftserv:applyInfo:add")
    @Log(title = "学生报名管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AfterServiceApplyInfo afterServiceApplyInfo)
    {
        return toAjax(afterServiceApplyInfoService.insertAfterServiceApplyInfo(afterServiceApplyInfo));
    }

    /**
     * 修改学生报名管理
     */
    @RequiresPermissions("aftserv:applyInfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AfterServiceApplyInfoQuery query = afterServiceApplyInfoService.selectAfterServiceApplyInfoQueryById(id);
        mmap.put("afterServiceApplyInfo", query);
        return prefix + "/edit";
    }

    /**
     * 修改保存学生报名管理
     */
    @RequiresPermissions("aftserv:applyInfo:edit")
    @Log(title = "学生报名管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AfterServiceApplyInfo afterServiceApplyInfo)
    {
        return toAjax(afterServiceApplyInfoService.updateAfterServiceApplyInfo(afterServiceApplyInfo));
    }

    /**
     * 删除学生报名管理
     */
    @RequiresPermissions("aftserv:applyInfo:remove")
    @Log(title = "学生报名管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(afterServiceApplyInfoService.deleteAfterServiceApplyInfoByIds(ids));
    }
}
